package com.ibeeking.found.cop.api.feign.fallback;

import com.ibeeking.found.cop.api.common.dto.CopEmployeeDTO;
import com.ibeeking.found.cop.api.feign.CopCpFeignClient;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;


/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
public class CopCpFeignFallbackFactory implements FallbackFactory<CopCpFeignClient> {
    @Override
    public CopCpFeignClient create(Throwable throwable) {
        return new CopCpFeignClient() {
            @Override
            public ResponseResult<CopEmployeeDTO> queryEmployeeByOpenUserId(@PathVariable("openUserId") String openUserId) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询员工信息失败!", null);
            }
        };
    }
}
